package com.bwie.utils;

import lombok.Data;

/**
 * 标准返回类
 */
@Data
public class ResultResponse {
    private Integer code;
    private String msg;
    private Boolean flag;


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Boolean getFlag() {
        return flag;
    }

    public void setFlag(Boolean flag) {
        this.flag = flag;
    }

    private Object data;

    public static  ResultResponse success() {
        ResultResponse resultResponse = new ResultResponse();
        resultResponse.setCode(200);
        resultResponse.setMsg("操作成功");
        resultResponse.setFlag(true);
        return resultResponse;
    }

    public static ResultResponse success(Object data){
        ResultResponse resultResponse = new ResultResponse();
        resultResponse.setCode(200);
        resultResponse.setMsg("操作成功");
        resultResponse.setData(data);
        resultResponse.setFlag(true);
        return resultResponse;
    }

    public static ResultResponse failed(int code) {
        ResultResponse resultResponse = new ResultResponse();
        resultResponse.setCode(code);
        resultResponse.setMsg("操作失败");
        resultResponse.setFlag(false);
        return resultResponse;
    }

    public static ResultResponse failed(int code,String msg){
        ResultResponse resultResponse = new ResultResponse();
        resultResponse.setCode(code);
        resultResponse.setMsg(msg);
        resultResponse.setFlag(false);
        return resultResponse;
    }

}
